<%@ page language="java" %>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.users.Functionality"%>
<%@ page import="org.apache.struts.util.LabelValueBean" %>
<%@ page import="java.util.ArrayList" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/specificationFileSetup.do" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); //try { %>
<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0" >

<SCRIPT language="JavaScript">

    window.onload = init;
    function init()
    {
        form = document.specificationFileSetupForm;

        if ( form.processStepId  != null)
        {
            qs_1 = new QuickSearch( form.processStepId, form.qs1, false);
        }
        if ( form.specFileId  != null)
        {
            qs_2 = new QuickSearch( form.specFileId, form.qs2, false);
        }
    }
    function submitPage()
    {
        var form = document.specificationFileSetupForm;
        form.action.value = "search";
        form.submit();
    }
    function loadValues()
    {
        var form = document.specificationFileSetupForm;
        form.action.value = "";
        form.submit();
    }
    function newSpecificationFileSetup()
	{
		var form = document.specificationFileSetupForm;
        if ( form.processName.value != '0' )
        {
            form.action.value="new";
            form.submit();
            return true;
        }
        else
        {
            var error = document.getElementById("errors");
            error.innerHTML = "Please Select Process Type";
        }
    }

    function reset()
    {
        form.reset();
        qs_1.resetQuickSearchCntrl();
        qs_2.resetQuickSearchCntrl();
    }

</SCRIPT>
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

    <!-- Side Navigation start -->
    <%@ include file="/jsp/operations/releaseMenu.jsp" %></TD>
    <!-- end of the side navigations -->

    <TD bgcolor="#ffffff">
    <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
    <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
    <TD valign="top" width="100%">

    <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
    <BR>

   	<html:form name="specificationFileSetupForm" action="/specificationFileSetup" method="POST" enctype="multipart/form-data" type="com.scalar.chiptrack.operations.release.forms.SpecificationFileSetupForm" scope="request">
        <input type="hidden" name="action" value="">
        <TABLE width='95%' align=right cellpadding='0' cellspacing='0' border='0'>
            <TR><Td class="NArialW" align=center>Specification File Setup</td></tr>
            <TR><TD><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <tr><td align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></td></tr>
            <TR><TD><chiptrack:errors styleClass="NArialL"/></TD></TR>
            <TR><TD><chiptrack:info styleClass="NArialL"/></TD></TR>
             <logic:equal name="showMessage" value="TRUE">
                <TR><TD><FONT class='NArialS'color='blue'><B><%=Constants.NO_MODIFY_RIGHTS %></B></FONT></TD></TR>
            </logic:equal>
            <TR><TD><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='7'></TD></TR>
            <TR><TD>&nbsp;</TD></TR>
            <TR>
                <TD width="100%">
                    <TABLE align="center" border="0" width="100%" cellspacing="3" cellpadding="2">

                        <logic:present name="partNumberList" >
                        <TR>
                        <TD COLSPAN=3>&nbsp;</TD>
                    <TD class="NArialL" width='15%'>Quick Search:</TD>
                    <td class="NArialL" width='20%'>
                    <input type="text" name="qs1" class="txfield" size='23' onkeyup='quickSearch(qs_1)'/>
                    </td>
                    <TD class="NArialL" width='15%'>&nbsp;</TD>
                    </TR>
                    </logic:present>
                        <TR>
                            <TD width="10%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top'>Process Type</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="processName" styleClass="txfield" onchange="javascript:loadValues();">
                                    <html:option value="0">--Select Process Type--</html:option>
                                    <html:option value="Sort">Sort</html:option>
                                    <html:option value="Assembly">Assembly</html:option>
                                    <html:option value="Test">Test</html:option>
                                </html:select>
                            </TD>

                            <TD width="15%" class="NArialL" valign = 'top' align = "center">Products &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="processStepId" styleClass="txfield" >
                                    <html:option value="0">--Select Product--</html:option>
                                    <html:options collection="partNumberList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>
                            <TD width="15%">&nbsp;</TD>
                        </TR>

                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=2></TD></TR>

                         <logic:present name="specFileNameList" >
                        <TR>
                        <TD COLSPAN=3>&nbsp;</TD>
                    <TD class="NArialL" width='15%'>Quick Search:</TD>
                    <td class="NArialL" width='20%'>
                    <input type="text" name="qs2" class="txfield" size='23' onkeyup='quickSearch(qs_2)'/>
                    </td>
                    <TD class="NArialL" width='15%'>&nbsp;</TD>
                    </TR>
                    </logic:present>
                        <TR>
                            <TD width="10%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' >Vendor</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="vendorId" styleClass="txfield" >
                                    <html:option value="0">--Select Vendor--</html:option>
                                    <html:options collection="vendorList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>
                            <TD width="15%" class="NArialL" valign='top'>Specification File</TD>
                            <TD width="20%" class="NArialL" valign='top'>
                                <html:select property="specFileId" styleClass="txfield" >
                                    <html:option value="0">--Select FileName--</html:option>
                                    <html:options collection="specFileNameList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>
                            <TD width="15%">&nbsp;</TD>
                        </TR>
                        <TR><TD width="10%" >&nbsp;</TD>
                            <TD colspan="2"><html:checkbox property="showSpecFilesWithOutPartNumbers" styleClass="txfield"  /><font class="NArialL">&nbsp;&nbsp;Show Old Specification Files</font></TD>
                        </TR>
                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></TD></TR>
                        <TR>
                            <TD colspan="6" align=center>
                                <a href="javascript:submitPage();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true" onmouseout="window.status='';return true" title='Click to Generate Report'></a>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="javascript:document.specificationFileSetupForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to reset search';return true" onmouseout="window.status='';return true" title="Click here to reset search"></a>
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
			</TR>
            <TR><TD class='NArialL'>To add a new Specification File Setup, please <A HREF="javascript:newSpecificationFileSetup();"  onmouseover="window.status='Click to Add New Specificaton File Setup';return true" onmouseout="window.status='';return true">click here</A></TD></TR>

            <nested:present name="specificationFileSetupForm" property="searchList">
            <TR><TD>&nbsp;</TD></TR>
            <TR>
                <TD>
                <nested:size id="size" name="specificationFileSetupForm" property="searchList"></nested:size>
                <logic:greaterThan name="size" value="0">
                <%
                    ArrayList vendorList = (ArrayList) request.getAttribute("vendorList");
                    vendorList.add(0, new LabelValueBean("All Vendors", "0"));
                %>
                <TABLE border="0" width="80%">
                      <TR>
                        <TD width="30%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Specification File Name</font></font></TD>
                        <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Revision Number</font></font></TD>
                        <logic:equal name="specificationFileSetupForm" value="Sort" property="processName">
                            <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Test Program Name</font></font></TD>
                            <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Test Program Revision</font></font></TD>
                            <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Test Flow</font></font></TD>
                        </logic:equal>
                      <logic:equal name="specificationFileSetupForm" value="Test" property="processName">
                          <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Test Program Name</font></font></TD>
                          <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Test Revision Number</font></font></TD>
                          <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Hot Test Flow</font></font></TD>
                          <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Room Temp Flow</font></font></TD>
                          <TD width="20%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">QA Test Flow</font></font></TD>
                      </logic:equal>
                        <TD width="25%" align="center" bgcolor="#993333" nowrap><font class="NArialL"><font color="#FFFFFF">Part Numbers&nbsp;/&nbsp;Vendors</font></font></TD>
                        <TD width="25%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Actions</font></font></TD>
                      </TR>
                <nested:iterate id="lineItem"  name="specificationFileSetupForm" property="searchList" type="com.scalar.chiptrack.operations.release.forms.SpecificationFileSetupForm">
                      <TR>
                        <TD width="30%" align="center" bgcolor="#DEE1E2" nowrap><font class="NArialL"><nested:write name="lineItem" property="specifincationFileName"/></font></TD>
                        <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="revisionNumber"/></font></TD>
                          <logic:equal name="specificationFileSetupForm" value="Sort" property="processName">
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="testProgramName"/></font></TD>
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="testProgramRevision"/></font></TD>
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="testFlow"/></font></TD>
                          </logic:equal>
                          <logic:equal name="specificationFileSetupForm" value="Test" property="processName">
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="postAssemblyTest"/></font></TD>
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="postAssemblyTestRev"/></font></TD>
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="hotTest"/></font></TD>
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="roomTempFlow"/></font></TD>
                              <TD width="20%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><nested:write name="lineItem" property="qaTest"/></font></TD>
                          </logic:equal>
                        <TD width="25%" align="center"  nowrap>
                             <table align="left" cellspacing="1" width="100%">
                            <nested:iterate id="partNumber"  name="lineItem" property="lineItemList" type="com.scalar.chiptrack.operations.release.SpecificationFileSetupPartNumber">

                                    <tr class="NArialL" width="100%">
                                        <td bgcolor="#DEE1E2"><%=   partNumber.getPartNumber() %></td>
                                        <td bgcolor="#DEE1E2">
                                            <%
                                                int[] vendorId = partNumber.getVendorId();
                                                if (vendorId == null) {
                                                    out.println("All Vendors");
                                                } else {
                                                    for (int i = 0; i < vendorId.length; i++) {
                                                        for (int j = 0; j < vendorList.size(); j++) {
                                                            LabelValueBean vendor = (LabelValueBean) vendorList.get(j);
                                                            if (vendor.getValue().equals(vendorId[i] + "")) {
                                                                out.println(vendor.getLabel() + "<BR>");
                                                            }
                                                        }
                                                    }
                                                }
                                            %>
                                        </td>
                                    </tr>

                                <%--<font class="NArialL"><%=   partNumber.getPartNumber() %></font><br>--%>
                            </nested:iterate>
                             </table>
                        </TD>
                        <TD width="25%" align="center" bgcolor="#DEE1E2" nowrap>
                            <font class="NArialL">
                                <a href="<%=chipTracContext%>/specificationFileSetup.do?action=View&specFileId=<nested:write name="lineItem" property="specId"/>" onmouseover="window.status='Click to View Specification File Setup';return true" onmouseout="window.status='';return true">View</a>
                                &nbsp;&nbsp;<a href="<%=chipTracContext%>/specificationFileSetup.do?action=modify&specFileId=<nested:write name="lineItem" property="specId"/>" onmouseover="window.status='Click to Modify Specification File Setup';return true" onmouseout="window.status='';return true">Modify</a>
                            </font>
                        </TD>
                      </TR>
                </nested:iterate>
                </TABLE>
            </logic:greaterThan>
               </TD>
            </TR>
            </nested:present>
            <TR><TD>&nbsp;</TD></TR>
            <tr height="30"><td colspan="4">&nbsp;</td></tr>
        </TABLE>
    </html:form>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>
<%--<% }
   catch(Exception e)
   {
       e.printStackTrace();
   }
    %>--%>
